﻿@{
	Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="page-header">
	<h3>修改登录密码</h3>
</div>

@using (Html.BeginForm("ChangePassword", "Account", FormMethod.Post, new { onsubmit = "return check_form()" }))
{
	<div class="panel panel-default" style="max-width:600px;">
		<div class="panel-heading">
			&nbsp;
		</div>

		<div class="panel-body form-horizontal">
			<div class="form-group">
				<label for="oldPassword" class="col-md-2 control-label">当前密码</label>
				<div class="col-md-7">
					<input id="txt_old_password" name="oldPassword" type="password" class="form-control" placeholder="请输入当前密码" />
				</div>
			</div>

			<div class="form-group">
				<label for="newPassword" class="col-md-2 control-label">新密码</label>
				<div class="col-md-7">
					<input id="txt_new_password" name="newPassword" type="password" class="form-control" placeholder="请输入新密码" />
				</div>
			</div>

			<div class="form-group">
				<label for="confirmNewPassword" class="col-md-2 control-label">确认密码</label>
				<div class="col-md-7">
					<input id="txt_confirm_new_password" type="password" class="form-control" placeholder="请再次输入新密码" />
				</div>
			</div>

			<div class="form-group">
				<div class="col-md-offset-2 col-md-7">
					<button type="submit" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-floppy-disk"></span> 保 存</button>
				</div>
			</div>
		</div>
	</div>
}

@section scripts {
	<script type="text/javascript">
		function check_form() {
			if ($("#txt_old_password").val() == '') {
				alert("请输入原密码");
				$("#txt_old_password").focus();
				return false;
			}

			if ($("#txt_new_password").val() == '') {
				alert("请输入新密码");
				$("#txt_new_password").focus();
				return false;
			}

			if ($("#txt_new_password").val() != $("#txt_confirm_new_password").val()) {
				alert("两次密码输入不一致");
				$("#txt_new_password").val('');
				$("#txt_confirm_new_password").val('');
				$("#txt_new_password").focus();
				return false;
			}

			return true;
		}
	</script>
}
